package per.jdz.demo.service.impl;

import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import per.jdz.demo.dao.PumpRecordDao;
import per.jdz.demo.domain.entity.PumpRecord;
import per.jdz.demo.domain.vo.reponse.PageBaseResp;
import per.jdz.demo.domain.vo.request.PumpPageReq;
import per.jdz.demo.service.PumpRecordService;

import static per.jdz.demo.domain.entity.table.PumpRecordTableDef.PUMP_RECORD;

@Slf4j
@Service
public class PumpRecordServiceImpl extends ServiceImpl<PumpRecordDao, PumpRecord> implements PumpRecordService {


    @Override
    public PageBaseResp<PumpRecord> pagePumpRecords(PumpPageReq req) {
        QueryCondition condition = QueryCondition.create(PUMP_RECORD.CLLTM, SqlOperator.GE, req.getStartTime()).
                and(QueryCondition.create(PUMP_RECORD.CLLTM, SqlOperator.LE, req.getEndTime()));
        Page<PumpRecord> page = page(req.flexPage(), condition);
        return PageBaseResp.init(page);
    }
}
